import java.util.Arrays;

public class Student implements Comparable<Student>{

    private String name;
    private int age;

    public Student() {
    }

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    public int compareTo(Student o) {
//        return this.age - o.age;
        return this.name.compareTo(o.name);
    }

    public static void main1(String[] args) {
        Student[] students = new Student[2];
        students[0] = new Student("zhangsan", 13);
        students[1] = new Student("lisi", 3);
        Arrays.sort(students);
        System.out.println(Arrays.toString(students));
    }

    public static void main11(String[] args) {
        Student student1 = new Student("zhangsan", 13);
        Student student2 = new Student("lisi", 3);

        System.out.println(student2.compareTo(student1));
    }

    public static void main(String[] args) {
        Student[] students = new Student[2];
        students[0] = new Student("zhangsan", 32);
        students[1] = new Student("lisi", 42);
        Arrays.sort(students);
        System.out.println(Arrays.toString(students));
    }
}
